package com.sc.controller.trigger;

import com.sc.service.trigger.TotalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/api/trigger")
@Api(tags = "查总数量")
public class TotalController {
    @Autowired
    private TotalService totalService;

    /**
     * 查询总数量
     * @return
     */
    @GetMapping("/total/{id}")
    @ApiOperation("查询总数量")
    public ResponseEntity<Integer> gettotalById(@PathVariable int id) {
        Integer total = totalService.getTotal(id);
        System.out.println("返回的 total：" + total);
        if (total == null) {
            return ResponseEntity.notFound().build();
        }
        return ResponseEntity.ok(total);
    }
}
